// 一级
import Layout from '@/views/Layout.vue'
import ArticleDetail from '@/views/ArticleDetail.vue'
import NotFound from '@/views/NotFound.vue'

// 二级
import Article from '@/views/Article.vue'
import Collect from '@/views/Collect.vue'
import Like from '@/views/Like.vue'
import User from '@/views/User.vue'

import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter) // VueRouter插件初始化

// 创建了一个路由对象
const router = new VueRouter({
  // 修改路由模式
  mode: 'hash',
  routes: [
   // 重定向
   //  {path: '/', redirect: '/home'}, 
   {
    path: '/', 
    component: Layout,
    children: [
      {path: '/', redirect: '/article'},
      {path: 'article', component: Article}, // /article
      {path: 'collect', component: Collect},
      {path: 'like', component: Like},
      {path: 'user', component: User},
    ]
   },
   {path: '/detail/:id', component: ArticleDetail},
   // 404
   {path: '*', component: NotFound}
  ]
})

export default router